home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / compat / tmpnam.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  1.0 KB  |  43 lines  |  [TEXT/CWIE]

  1. /*
  2.  * Copyright (c) 1988 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that this notice is preserved and that due credit is given
  7.  * to the University of California at Berkeley. The name of the University
  8.  * may not be used to endorse or promote products derived from this
  9.  * software without specific written prior permission. This software
  10.  * is provided ``as is'' without express or implied warranty.
  11.  *
  12.  * SCCS: @(#) tmpnam.c 1.3 96/02/15 12:08:25
  13.  */
  14.  
  15. #include <sys/param.h>
  16. #include <sys/stat.h>
  17. #include <sys/file.h>
  18. #include <stdio.h>
  19.  
  20. /*
  21.  * Use /tmp instead of /usr/tmp, because L_tmpname is only 14 chars
  22.  * on some machines (like NeXT machines) and /usr/tmp will cause
  23.  * buffer overflows.
  24.  */
  25.  
  26. #ifdef P_tmpdir
  27. #   undef P_tmpdir
  28. #endif
  29. #define    P_tmpdir    "/tmp"
  30.  
  31. char *
  32. tmpnam(s)
  33.     char *s;
  34. {
  35.     static char name[50];
  36.     char *mktemp();
  37.  
  38.     if (!s)
  39.         s = name;
  40.     (void)sprintf(s, "%s/XXXXXX", P_tmpdir);
  41.     return(mktemp(s));
  42. }
  43.